<?php  
//thu trang
class ControllerMartCrmgoodsgroup3 extends Controller { 
    
   
  	public function index() {
            
             if (isset($this->request->get['id_group_2'])) {
                    
			$id_group_2 = $this->request->get['id_group_2'];
		} 
		$this->load->language('Mart_Crm/CRM_Report');
		$this->load->model('Mart_Crm/goodsgroup3');
                
                if (isset($this->request->get['filter_date_start'])) {
			$filter_date_start = $this->request->get['filter_date_start'];
                                              
		} else {
			$filter_date_start = date('Y-m-d', strtotime(date('Y') . '-' . date('m') . '-01'));
                        //echo $filter_date_start;
		}

		if (isset($this->request->get['filter_date_end'])) {
			$filter_date_end = $this->request->get['filter_date_end'];
		} else {
			$filter_date_end = date('Y-m-d');
		}
                
                $url = '';
						
		if (isset($this->request->get['filter_date_start'])) {
			$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
		}
		
		if (isset($this->request->get['filter_date_end'])) {
			$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
		}


                
                $this->data['rows'] = array();
		
		$data = array(
                        'id_group_2' => $id_group_2,
			'filter_date_start'	     => $filter_date_start, 
			'filter_date_end'	     => $filter_date_end, 
		);

                if (isset($this->request->get['print'])) {
                    
			 $this->data['print'] = $this->request->get['print'];
		} else {
			 $this->data['print'] = "false";
		}
               
                $print =  $this->data['print'];
		$results = $this->model_Mart_Crm_goodsgroup3->getGoodsGroup3($data);

              
                //print_r($results);
//               $this->data['rows'][] = array(
//                            
//                            'id'=> null,
//                            'name'=> null,
//                            'amount'=> null
//                       
//                        );
               
                $this->data['text_no_results'] = $this->language->get('text_no_results');

		$this->data['token'] = $this->session->data['token'];
		$this->data['heading_title'] = $this->language->get('heading_title');
		
		$this->data['column_date_start'] = $this->language->get('column_date_start');
		$this->data['column_date_end'] = $this->language->get('column_date_end');
		
		$this->data['entry_date_start'] = $this->language->get('entry_date_start');
		$this->data['entry_date_end'] = $this->language->get('entry_date_end');
		$this->data['entry_group'] = $this->language->get('entry_group');	

		$this->data['button_export_pdf'] = $this->language->get('button_export_pdf');
               $this->data['button_export_excel'] = $this->language->get('button_export_excel');
                $this->data['button_display'] = $this->language->get('button_display');
                
                $this->data['STT'] = $this->language->get('STT');
                $this->data['goods_name'] = $this->language->get('goods_name');
                $this->data['group_name'] = $this->language->get('group_name');
                $this->data['Doanhthu'] = $this->language->get('Doanhthu');
                
                $this->data['entry_group'] = $this->language->get('entry_group');				        
                           
                       
                        
                foreach ($results as $result) {
			$this->data['rows'][] = array(
                            
                            'id_group_3'=> $result['id_group_3'],
                            'name'=> $result['name'],
                            'amount'=> $result['amount'],
                            'href' => $this->url->link('Mart_Crm/customer_rfid_report/index', 'token=' . $this->session->data['token'] . '&id_group_3=' . $result['id_group_3'].'&id_group_2=' . $id_group_2.'&filter_date_start='.$filter_date_start.'&filter_date_end='.$filter_date_end , 'SSL')
                        );
			
			}
                // = true;
                        if($print == "false")
                        {
                $this->template = 'Mart_Crm/goodsgroup3.tpl';
                $this->data['print'] = $this->url->link('Mart_Crm/goods_group_3/index', 'token=' . $this->session->data['token'].'&id_group_3=' . $result['id_group_3'].'&id_group_2=' . $id_group_2.'&filter_date_start='.$filter_date_start.'&filter_date_end='.$filter_date_end.  '&print=true');
                        }
                        if($print == "true")
                        {
                $this->template = "Mart_Crm/goodsgroup3print.tpl";
                
                        }
                         $this->data['export_excel'] = $this->url->link('tool/export/downloadgoodgroup3', 'token=' . $this->session->data['token'].'&id_group_3=' . $result['id_group_3'].'&id_group_2=' . $id_group_2.'&filter_date_start='.$filter_date_start.'&filter_date_end='.$filter_date_end);
                        
		$this->children = array(
			'common/header',	
			'common/footer'	
		);
                
		
		$this->response->setOutput($this->render());
		
		
  	}
}
?>
